Skip to content

feat(chat): add --timeout option to ask command#260

Open
Flosters wants to merge 2 commits intoteng-lin:mainfrom
Flosters:feat/ask-timeout
Open

feat(chat): add --timeout option to ask command#260
Flosters wants to merge 2 commits intoteng-lin:mainfrom
Flosters:feat/ask-timeout

Conversation

@Flosters
Copy link
Copy Markdown

@Flosters Flosters commented Apr 9, 2026

Summary

Long or complex prompts can exceed the default HTTP timeout, causing notebooklm ask to fail silently with a connection error. There is currently no way to increase this without changing client-wide settings in code.

This PR adds a --timeout option (default: 120s) to the ask command, letting users increase it for slower responses.

Usage:

$ notebooklm ask "summarize everything across all 50 sources" --timeout 300

Changes

  • cli/chat.py: add --timeout (int, default 120, show_default=True) to ask
    • Passed as timeout=float(timeout) to NotebookLMClient()
    • Scoped to the ask invocation only — no effect on other commands

Test plan

  • notebooklm ask --help shows --timeout INTEGER with default [default: 120]
  • notebooklm ask "question" --timeout 300 uses the extended timeout
  • Default behavior (no flag) is unchanged

Summary by CodeRabbit

  • New Features
    • The CLI ask command now accepts a --timeout option (integer, min 1, default 120). Users can control how long the command waits for a response, improving control over long-running or slow requests and avoiding reliance on built-in defaults. This change affects the request timeout behavior for interactive chat runs.

Long or complex prompts can exceed the default HTTP timeout, causing the
request to fail silently. Adding --timeout (default: 120s) lets users
increase this for slower responses without changing client-wide settings.

Usage:
  notebooklm ask "summarize everything" --timeout 300
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ee929a7-bd58-416a-96bb-415f8b9b856a

📥 Commits

Reviewing files that changed from the base of the PR and between c5f56e0 and e7c6d19.

📒 Files selected for processing (1)
  • src/notebooklm/cli/chat.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/notebooklm/cli/chat.py

📝 Walkthrough

Walkthrough

The ask CLI command gained a --timeout integer option (default 120, min 1). The handler now forwards this value to NotebookLMClient as a float tuple for request timeouts.

Changes

Cohort / File(s) Summary
CLI Timeout Option
src/notebooklm/cli/chat.py
Added --timeout CLI option (int, default 120, min=1) to ask and threaded the value into NotebookLMClient(client_auth, timeout=(10.0, float(timeout))), replacing the prior implicit/default timeout behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇⏳ I nibble at seconds, counting with care,
A little hop, a timeout set fair.
One-twenty the default, adjustable too,
So prompts finish neat — quick, calm, and true.
Hop on, configure; the client waits for you.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(chat): add --timeout option to ask command' directly and accurately summarizes the main change: adding a new --timeout CLI option to the ask command.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a configurable --timeout option for the ask_cmd command in the NotebookLM CLI, allowing users to adjust the request timeout for long prompts. The feedback suggests refining the CLI option by using click.IntRange to ensure positive values and removing redundant default text from the help string. Additionally, it is recommended to implement granular timeouts (separating connection and read timeouts) when initializing the NotebookLMClient to improve network resilience.

Comment on lines +105 to +111
@click.option(
"--timeout",
default=120,
type=int,
show_default=True,
help="Request timeout in seconds. Increase for long prompts (default: 120).",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The help text contains a redundant default value since show_default=True is enabled, which will cause Click to append [default: 120] automatically. Additionally, the timeout should be validated to ensure it is a positive value to avoid potential issues with the underlying network client.

Suggested change
@click.option(
"--timeout",
default=120,
type=int,
show_default=True,
help="Request timeout in seconds. Increase for long prompts (default: 120).",
)
@click.option(
"--timeout",
default=120,
type=click.IntRange(min=1),
show_default=True,
help="Request timeout in seconds. Increase for long prompts.",
)

Comment thread src/notebooklm/cli/chat.py Outdated

async def _run():
async with NotebookLMClient(client_auth) as client:
async with NotebookLMClient(client_auth, timeout=float(timeout)) as client:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Following the general rules for network clients, it is recommended to use granular timeouts. A single float value sets the same timeout for connection and reading. Using a shorter connect timeout (e.g., 10s) while allowing a longer read timeout improves resilience by failing fast on connection issues while still accommodating slow responses. Note that the NotebookLMClient type hints should also be updated to support this.

Suggested change
async with NotebookLMClient(client_auth, timeout=float(timeout)) as client:
async with NotebookLMClient(client_auth, timeout=(10.0, float(timeout))) as client:
References
  1. For network clients, use granular timeouts with a shorter connect timeout and longer read/write timeouts to improve resilience by detecting connection issues quickly while accommodating slow responses.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/notebooklm/cli/chat.py`:
- Around line 105-111: The --timeout click option currently uses type=int which
permits 0 and negative values; change its validation to require strictly
positive integers by replacing type=int with click.IntRange(min=1) (or add a
callback that raises click.BadParameter if timeout < 1) in the `@click.option`
declaration for "--timeout" in chat.py so the CLI rejects non-positive values at
parse time and returns a clear validation error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42881f76-bc63-4350-9e68-f8b5eac381d9

📥 Commits

Reviewing files that changed from the base of the PR and between a997718 and c5f56e0.

📒 Files selected for processing (1)
  • src/notebooklm/cli/chat.py

Comment thread src/notebooklm/cli/chat.py
- Use click.IntRange(min=1) instead of type=int to validate positive
  values at parse time rather than failing at runtime
- Remove redundant "(default: 120)" from help text since show_default=True
  already appends it automatically
- Use tuple timeout=(10.0, float(timeout)) for granular connect/read
  timeouts, providing faster failure detection on connection errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant